package com.chapter17;

public class FinancialCalculations
  {
   public static final int MONTHS_IN_YEAR = 12;

   public static double calculateFutureValue (double monthlyPayment, double yearlyInterestRate, int years)
     {
      int    months              = years * MONTHS_IN_YEAR;
      double monthlyInterestRate = yearlyInterestRate/MONTHS_IN_YEAR/100;
      double futureValue         = 0;
      for (int i = 1; i <= months; i++)
        {
         futureValue = (futureValue + monthlyPayment) * (1 + monthlyInterestRate);
        }
      return futureValue;
     }
  }